using System.Linq.Expressions;
using Common.CustomEnums;
namespace IRepositories
{
	public partial interface IBaseRepository<TEntity> where TEntity : class
	{
		#region Create
        /// <summary>
        /// 新增一个实体
        /// </summary>
        /// <param name="entity">待新增实体</param>
        /// <returns>是否创建成功true/false</returns>
        bool Create(TEntity entity);
        /// <summary>
        /// 批量新增实体
        /// </summary>
        /// <param name="entities">待新增的多个实体</param>
        /// <returns>是否创建成功true/false</returns>
        bool Create(IEnumerable<TEntity> entities);
        /// <summary>
        /// 新增一个实体
        /// </summary>
        /// <param name="entity">待新增实体</param>
        /// <returns>创建的实体</returns>
        TEntity CreateEntity(TEntity entity);
        /// <summary>
        /// 批量新增实体
        /// </summary>
        /// <param name="entities">待新增的多个实体</param>
        /// <returns>创建的实体</returns>
        IEnumerable<TEntity> CreateEntity(IEnumerable<TEntity> entities);
        #endregion

        #region Delete
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="Id">待删除数据的主键</param>
        /// <returns>是否删除成功true/false</returns>
        bool Delete(object Id);
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="Ids">待删除的数据主键</param>
        /// <returns>是否删除成功true/false</returns>
        bool Delete(IEnumerable<object> Ids);

        bool Delete(Expression<Func<TEntity,bool>> expression);
        #endregion

		#region Update
        bool Update(TEntity entity);

        bool Update(IEnumerable<TEntity> entities);

		#endregion

		#region Query
        TEntity? Query(object Id);

        IQueryable<TEntity> Query();

		TEntity? QueryWhere(Expression<Func<TEntity,bool>> whereExpression);

        IQueryable<TEntity> Query(Expression<Func<TEntity,bool>> whereExpression);

        IQueryable<TEntity> Query<TOrder>(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, TOrder>> orderExpression,SortOrder order = SortOrder.Ascending);

        IQueryable<TEntity> Query<TOrder>(Expression<Func<TEntity, bool>>? whereExpression = null, Expression<Func<TEntity, TOrder>>? orderExpression = null, SortOrder order = SortOrder.Ascending, int pageIndex = 0, int pageSize = 0);
        
        #endregion

        

        
	}
}
